﻿@using CVsharp.Models.Entities
@{
    ViewBag.Title = "权限管理";
    Layout = "~/Views/Shared/Dwz/_DwzPageLayout.cshtml";
}
<link href="../../Content/themes/tree.css" rel="stylesheet" type="text/css" />
<div id="resultBox">
</div>
<div class="divider">
</div>
<div class="tabs">
    <div class="tabsHeader">
        <div class="tabsHeaderContent">
            <ul>
                <li><a href="javascript:;"><span>权限管理</span></a></li>
                <li><a href="javascript:;"><span>人员管理</span></a></li>
            </ul>
        </div>
    </div>
    <div class="tabsContent">
        <div>
            <div layouth="100" style="float: left; display: block; overflow: auto; width: 200px;
                border: solid 1px #99BBE8; line-height: 21px; background: #fff; margin-right: 10px;">
                <div class="panelBar">
                    <ul class="toolBar">
                        <li class=""><a class="add" target="dialog" href=""><span>添加用户</span> </a></li>
                        <li class=""><a class="add" id="UserJoinRole" target="dialog"><span>加入角色</span> </a>
                        </li>
                    </ul>
                </div>
                <ul id="dwztree" class="tree treeFolder expand" oncheck="kkk">
                    @foreach (MembershipUser u in Membership.GetAllUsers())
                    { 
                        <li title="@u.UserName" ><a>@u.UserName</a> </li>
                    }
                </ul>
            </div>
            <div layouth="100" style="float: left; display: block; overflow: auto; width: 200px;
                border: solid 1px #99BBE8; line-height: 21px; background: #fff; margin-right: 10px;">
                <div class="panelBar">
                    <ul class="toolBar">
                        <li class=""><a class="add"><span>添加角色</span> </a></li>
                    </ul>
                </div>
                <div id="RolesTree">
                </div>
            </div>
            <div layouth="100" style="float: left; display: block; overflow: auto; width: 300px;
                border: solid 1px #99BBE8; line-height: 21px; background: #fff;">
                <ul id="dwztree" class="tree treeFolder treeCheck expand" oncheck="treeOncheck">
                    @foreach (string ControllerName in ((List<sysActionPermission>)ViewData["aps"]).Select(m => m.ControllerName).Distinct())
                    {
                        <li><a>
                            @ControllerName</a>
                            <ul>
                                @foreach (sysActionPermission ap in ((List<sysActionPermission>)ViewData["aps"]).Where(m => m.ControllerName == ControllerName).OrderByDescending(m => m.IsViewPage))
                                {
                                    <li class="sysActionPermission"><a tname="name" tvalue="@ControllerName.@ap.ActionName" checked="false">@ap.Description:@ap.ActionName
                                        @if (ap.IsViewPage)
                                        {
                                            <text>(页面)</text>
                                        }
                                        else
                                        { 
                                            <text>(功能)</text>
                                        }
                                    </a></li>
                                }
                            </ul>
                        </li>
                    }
                </ul>
            </div>
            <div>
            </div>
            <div id="jbsxBox" class="unitBox" style="margin-left: 246px;">
                <!--#include virtual="list1.html" -->
            </div>
        </div>
    </div>
    <div class="tabsFooter">
        <div class="tabsFooterContent">
        </div>
    </div>
</div>
<script type="text/javascript">
    function loadRolesTree(){
        $("#RolesTree").ajaxUrl({
					type:"POST", url:"@Url.Action("RolesTree")", callback:function(response){
					}
				});
                } 
    loadRolesTree();
    function treeOncheck() {
        var json = arguments[0], result = "";
        //alert(json.checked);
        //alert(json.toString());
        $(json.items).each(function (i) {
            result += "<p>name:" + this.name + " value:" + this.value + " text: " + this.text + " checked:" + json.checked + "</p>";
        });
        $("#resultBox").html(result);
    }
    function btnSavw_onclick() {
    }
    $("#UserJoinRole").click(function () {
        $.post("GradeManage/GradeConfigHandler.ashx ",
            {                
                gradeExplanation: $("#GradeExplanation").val()
            },
        function (data, textStatus)
         { alertMsg.correct('加入成功！'); }, "json");
    });
</script>
